﻿//Datepicker initialization
function addDatePicker(id) {
    $("#" + id).datepicker({ dateFormat: 'dd/mm/yy'}); //, appendText: ' (dd/mm/yyyy)' });
}

// JGrowl information message:
function InformationMessage(message, stayTime) {
    if (stayTime == null) {
        stayTime = 4000
    }
    $().toastmessage('showToast', { text: message, type: 'success', stayTime: stayTime });
}
// JGrowl error message:
function ErrorMessage(message, stayTime) { 
    if (stayTime == null) {
        stayTime = 4000
    }
    $().toastmessage('showToast', { text: message, type: 'error', stayTime: stayTime });
}


// Confirm dialog:
function ConfirmDialog(divid, onok) {
    $("#" + divid).dialog({
        resizable: false,
        height: 140,
        modal: true,
        buttons: {
            'OK': function () {
                $(this).dialog('close');
                onok();
            },
            Cancel: function () {
                $(this).dialog('close');
            }
        }
    });

}

function toggleVisibility(id) {
    var obj = $("#" + id);
    if (obj.is(":visible")) {
        obj.hide('slow');
    }
    else {
        obj.show('slow');
    }
}
